var xiaoka = {

	// iosUrl:"https://appstoreconnect.apple.com/login?targetPrefix=%2FWebObjects%2FiTunesConnect.woa&targetUrl=%2Fra%2Fng%2Fapp%2F1469760149&authResult=FAILED",
	iosUrl:"https://apps.apple.com/cn/app/e%E6%97%8F%E5%87%BA%E8%A1%8C%E5%8F%B8%E6%9C%BA%E7%AB%AF/id1470370306",
	browser: function() {
		var u = navigator.userAgent,
			app = navigator.appVersion;
		return { //移动终端浏览器版本信息 
			trident: u.indexOf('Trident') > -1, //IE内核
			presto: u.indexOf('Presto') > -1, //opera内核
			webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
			gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
			mobile: !! u.match(/AppleWebKit.*Mobile.*/) || !! u.match(/AppleWebKit/), //是否为移动终端
			ios: !! u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
			android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
			iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
			iPad: u.indexOf('iPad') > -1, //是否iPad
			webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
		};
	}(),
	language: (navigator.browserLanguage || navigator.language).toLowerCase(),
	is_weixin: function() {
		var ua = navigator.userAgent.toLowerCase();
		if (ua.match(/MicroMessenger/i) == "micromessenger") {
			return true;
		} else {
			return false;
		}
	},
	downloadLink:function(android,ios,auto){
		//生成下载链接
		console.log(xiaoka.browser)
		var str = '';
		if(xiaoka.browser.android){
	    	str += '<a class="down-list ios-box" href="'+android+'"><span class="dl-info"><img src="http://app.daijia.wang/assets/img/app-android.png" width="60" height="60"><b>安卓下载</b></span></a>';
		}
		if(xiaoka.browser.ios || xiaoka.browser.iPhone || xiaoka.browser.iPad){
        	str += '<a class="down-list ios-box" href="'+ios+'"><span class="dl-info"><img src="http://app.daijia.wang/assets/img/app-apple.png" width="60" height="60"><b>苹果下载</b></span></a>';
		}
		document.getElementById('content').innerHTML=str;
		// console.log(xiaoka.browser);
		//生成提示内容
		if(xiaoka.is_weixin()){
			if(xiaoka.browser.ios || xiaoka.browser.iPhone || xiaoka.browser.iPad){
				document.getElementById('tip').innerHTML='<img width="100%" src="http://app.daijia.wang/assets/img/tip-apple.png">';
			}else{
				document.getElementById('tip').innerHTML='<img width="100%" src="http://app.daijia.wang/assets/img/tip-android.png">';
			}
		}
		//自动下载
		if(auto){
			setTimeout(function(){
				if(xiaoka.browser.ios || xiaoka.browser.iPhone || xiaoka.browser.iPad){
					window.location = ios;
					// console.log(ios)
				}else if(xiaoka.browser.android){
					window.location.href = android;
				}
			
			},500);
		}
	}
}


